'use strict';
module.exports = {
	/**
	 * XXXnameXXX
	 * @url admin/avatar-template/sys/setUserTemplate 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid, templateIds, uid } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
    let dbName = "avatar-user-template";
    let data = templateIds.map(id => {
      return {
        userId: uid,
        templateId: id,
        buyTime: vk.pubfn.timeFormat(new Date(),"yyyy-MM-dd hh:mm:ss")
      }
    })
		res.ids  = await vk.baseDao.add({
			dbName,
			dataJson: data
		});

		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
